Merged
Conversation
…astructure Introduces the foundation for multi-group support: - GroupConfig (Pydantic BaseModel) with per-group settings - GroupRegistry for O(1) group lookup - JSON file loading and backward-compatible fallback from .env - get_group_config_for_update() helper for handlers - Module-level singleton with init/get/reset Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds configurable path for groups.json file (defaults to "groups.json"). Existing .env fields kept for backward compatibility when no groups.json exists. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rvice Per-group variant that filters by group_id AND uses group-specific threshold, enabling different auto-restriction timing per group. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Universal pattern change across all group-facing handlers: - topic_guard: uses get_group_config_for_update for guard check - anti_spam: per-group probation thresholds and violation tracking - message: per-group warning/restriction with group-specific settings - captcha: accepts GroupConfig, looks up group from registry on callback - verify: iterates all groups for unrestrict/delete-warnings - check: sends warnings to all monitored groups - dm: iterates all groups for membership check and cross-group unrestriction Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Scheduler iterates per-group with group-specific thresholds - Captcha recovery uses per-group timeout from GroupConfig - Skips captchas for groups no longer in registry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Initialize group registry from settings (groups.json or .env fallback) - Fetch admin IDs per-group and store union for DM commands - Captcha recovery checks all groups with captcha enabled - Log per-group config summary at startup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- groups.json.example with sample multi-group configuration - .env.example documents GROUPS_CONFIG_PATH option - .gitignore excludes groups.json (contains group IDs) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🔄 Replace get_settings() patches with get_group_config_for_update() and get_group_registry() patches across all test files. 🆕 Add test_group_config.py for GroupConfig, GroupRegistry, JSON loading, and singleton management. 🎯 All 440 tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GroupConfig(Pydantic model) andGroupRegistryfor per-group configuration (warning topic, restriction settings, captcha, thresholds)groups.jsonfile for multi-group config with automatic fallback to.envfor single-group backward compatibilitytopic_guard,anti_spam,message,captcha,verify,check,dm) to useget_group_config_for_update()instead ofsettings.group_idmain.pyto initializeGroupRegistryand fetch per-group admin IDstest_group_config.pyHighlights
groups.json? Bot works exactly as before using.envvalueswarning_topic_id,restrict_failed_users,warning_threshold,captcha_enabled,captcha_timeout_seconds,rules_link, etc./verify,/check)group_id(must be negative), thresholds (must be positive), captcha timeout (10-600s range)Test plan
uv run pytest tests/ -v)groups.json, run bot with.envonlygroups.jsonwith 2+ groups, verify per-group behaviorgroups.json(invalid JSON, duplicate IDs, positive group_id)🤖 Generated with Claude Code